﻿using AIVision.Model.UIModels;
using Prism.Commands;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace AIVision.UI.ViewModels
{
    public class TopViewModel: BindableBase
    {
        private readonly IRegionManager regionManager;
        private readonly SummaryDataModel summaryData;

        public DelegateCommand<string> MenuCommand { get; private set; }
        public TopViewModel(IRegionManager regionManager, SummaryDataModel summaryData)
        {
            MenuCommand = new DelegateCommand<string>(MenuMethod);
            this.regionManager = regionManager;
            this.summaryData = summaryData;
        }


        private void MenuMethod(string menuName)
        {
            if(menuName =="Exit")
            {
                if (summaryData.AllQty > 0)
                {
                    MessageBox.Show("请先保存检查数据!");
                    return;
                }
                else
                {
                    Application.Current.Shutdown();
                    return;
                }
            }
                

            var v = regionManager.Regions["MainRegion"];
            v.RequestNavigate(menuName);
        }
    }
}
